#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time


class BasicStat(object):
    def incr(self, business, field, increment=1, extra=None):
        pass


class RdsStat(BasicStat):
    def __init__(self, rds):
        self.rds = rds

    def incr(self, business, field, increment=1, extra=None):
        if self.rds is not None:
            cur_tm = time.strftime('%Y%m%d%H', time.localtime())
            field = '{0}_{1}'.format(field, cur_tm)
            return self.rds.hincrby(business, field, increment)
        return 0
